﻿using B.S.DataBase.MyProject.Domain.wdx;
using B.S.DataBase.MyProject.ErrorCode;
using B.S.DataBase.MyProject.Infrastructure;
using MediatR;
using MedicalPCTerminal.Read.API.Appcation.Commands.Sign;

namespace MedicalPCTerminal.Read.API.Appcation.CommandHandlers.Sign
{
    public class GetServicesPackCommandHandler:IRequestHandler<GetServicesPackCommand, APIResult<List<ServicesPack>>>
    {
        private readonly SqlSugarContext sqlSugar;

        public GetServicesPackCommandHandler(SqlSugarContext sqlSugar)
        {
            this.sqlSugar = sqlSugar;
        }

        public Task<APIResult<List<ServicesPack>>> Handle(GetServicesPackCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<ServicesPack>> result = new APIResult<List<ServicesPack>>();
            result.data = sqlSugar.db.Queryable<ServicesPack>().ToList();
            result.Code = APIEnum.查询成功;
            result.Msg = APIEnum.查询成功.ToString();
            return Task.FromResult(result);
        }
    }
}
